package gcc;

import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;

/**
 * @author CBeann
 * @create 2020-04-19 1:43
 */
public class HelloGC1_5 {
  public static void main(String[] args) throws Exception {

    int size = 700;

    for (int i3 = 0; i3 < 100; i3++) {
      Class<?> clazz = Class.forName("gcc.TestModel");

      TestModel testModel = new TestModel();



      for (int i = 0; i < size; i++) {

        //jni调用转为本地调用
        int inflationThreshold = 16;

        for (int i1 = 0; i1 < inflationThreshold; i1++) {
          Method method = clazz.getMethod("setField" + i, String.class);
          method.invoke(testModel, String.valueOf(i));
        }
      }




      Class<?> clazzTestMode2 = Class.forName("gcc.TestModel2");
      TestModel2 testMode2 = new TestModel2();
      for (int i = 0; i < size; i++) {

        //jni调用转为本地调用
        int inflationThreshold = 16;

        for (int i1 = 0; i1 < inflationThreshold; i1++) {
          Method method = clazzTestMode2.getMethod("setField" + i, String.class);
          method.invoke(testMode2, String.valueOf(i));
        }
      }


      Class<?> clazzTestMode3 = Class.forName("gcc.TestModel3");
      TestModel3 testMode3 = new TestModel3();
      for (int i = 0; i < size; i++) {

        //jni调用转为本地调用
        int inflationThreshold = 16;

        for (int i1 = 0; i1 < inflationThreshold; i1++) {
          Method method = clazzTestMode3.getMethod("setField" + i, String.class);
          method.invoke(testMode3, String.valueOf(i));
        }
      }


      Class<?> clazzTestMode4 = Class.forName("gcc.TestModel4");
      TestModel4 testMode4 = new TestModel4();
      for (int i = 0; i < size; i++) {

        //jni调用转为本地调用
        int inflationThreshold = 16;

        for (int i1 = 0; i1 < inflationThreshold; i1++) {
          Method method = clazzTestMode4.getMethod("setField" + i, String.class);
          method.invoke(testMode4, String.valueOf(i));
        }
      }
    }

    try {
      TimeUnit.SECONDS.sleep(Integer.MAX_VALUE);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
    }

  }
}
